﻿using System;
using System.Windows.Automation;

namespace QuickUIT.Controls
{
    /// <summary>
    /// Represents a tab item control. 
    /// </summary>
    public class UITabItem : UIBaseControl
    {
        /// <summary>
        /// Gets a value that indicates whether the tab item is selected. 
        /// </summary>
        public new bool IsSelected
        {
            get { return base.IsSelected; }
        } 

        /// <summary>
        /// Initializes a new instance of the <see cref="UITabItem"/> class. 
        /// </summary>
        public UITabItem() : base(ControlType.TabItem)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UITabItem"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        public UITabItem(UIBaseControl parent) : base(parent, ControlType.TabItem)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UITabItem"/> class.
        /// </summary>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UITabItem(string locator) : base(null, ControlType.TabItem, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UITabItem"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UITabItem(UIBaseControl parent, string locator) : base(parent, ControlType.TabItem, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UITabItem"/> class.
        /// </summary>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UITabItem(AutomationElement control) : base(control, ControlType.TabItem)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UITabItem"/> class.
        /// </summary>
        /// <param name="parent">The parent of the control</param>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UITabItem(UIBaseControl parent, AutomationElement control) : base(parent, control, ControlType.TabItem)
        {
        }

        /// <summary>
        /// Selects the current tab item. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void Select()
        {
            base.Select();
        }

        /// <summary>
        /// Gets the parent selection container of a control. 
        /// </summary>
        /// <returns>The <see cref="AutomationElement"/> of the parent control that implements the <see cref="SelectionPattern"/>.</returns>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new AutomationElement GetSelectionContainer()
        {
            return base.GetSelectionContainer(); 
        }
    }
}
